/**
Location mode
A specific group of characters can be sent to a location to explore, fully equipped and armed
Characters can be selected from the bottom bar into points of the location to explore
They can examine objects, enter rooms, use items (flashlight, explosive, key), or attack
If a combat event happens (started by a character) -> Combat mode

Once a location is cleared (or is found that way) it can be looted, or occupied.
*/

#include "Location.h"
#include "GameApp.h"

Location::Location() :
curLayer(-1),
selectedAction(Action_None)
{
}

void Location::start()
{
	//load location data from app
	//scene: background image/s, enemies
	//initialize characters on location from profile
	//GameApp::instance->player
	
	//location metadata: background/map (layers),
	//enemies (type, stats, position in map), items (sku, level, position in map)
	//cover points
	//default layer/position
	//setLayerVisible(defaultLayer);

	//input layer
	//get input events
}

void Location::stop()
{
	//destroy location scene
}

void Location::setLayerVisible(int _curLayer)
{
	if (curLayer != _curLayer) {
		curLayer = _curLayer;
		for (int layer = 0; layer < layers.size(); layer++)
			;//layers[layer]->setVisible(layer == curLayer);
	}
}

void Location::onEvent(/*events::Event* event*/)
{
	switch (selectedAction) {
	case Action_Move:
		//if (event->type == events::TOUCH_TAP) {
		//static_cast<events::InputTap*>(event)->touchPos
		//determine if the touch hit a walkable area, a character or an item
		//for an item, move towards the item position
		//for a character, move towards the character, if it's reachable
		//finally, find a walkable position determined by this point for moving
		break;
	case Action_Shoot:
		//if (event->type == events::TOUCH_MOVE)
		//move the cross hair
		//if (event->type == events::TOUCH_TAP)
		//check if the tap is in the area of the crosshair
		//find if there is an item, enemy or background
		//and shoot, 
		break;
	}
}
